package com.teaphy.data;


import com.teaphy.interfaces.Study;
import com.teaphy.interfaces.Swim;
import com.teaphy.annotations.Author;
import com.teaphy.annotations.Explain;

import java.util.Arrays;

@Author(authors = "t1", time = "2019-02-19-1", version = 1)
@Explain("this class describes the information of the student")
public class Student<T> extends Person implements Study, Swim {

	@Explain("show the current age")
	protected int age;

	public Integer sex;

	public Location location;

	@Author(authors = "t1", time = "2019-02-19-1", version = 1)
	@Explain("this field describes the information of the location")
	public String addr;

	private int sorted;

	public T t;

	public Student() {
		System.out.println("默认构造函数被调用");
	}

	@Author(authors = "t2", time = "2019-02-19-2", version = 1)
	public <V, Z> Student(int age, String addr, T t, V v, Z z) {
		this.age = age;
		this.addr = addr;
		this.t = t;
	}

	public Student(int id, int age, String... params)
			throws ArrayIndexOutOfBoundsException, NullPointerException {
		super(id);
		this.age = age;
	}

	public Student(String name) {
		super(name);
	}

	public Student(int id) {
		super(id);
	}

	@Author(authors = "t3", time = "2019-02-19-4", version = 1)
	Student(String name, int age, String addr) {
		super(name);
		this.age = age;
		this.addr = addr;
	}

	@Author(authors = "teaphy", time = "2019-03-04", version = 1)
	@Explain("this method is used for the test of Method")
	public <T, V, Z> String testMethod(@Author(authors = "teaphy", version = 1) @Explain("name") String name,
	                                   T t,
	                                   V v,
	                                   @Author(authors = "teaphy", version = 1) int... number)
			throws StringIndexOutOfBoundsException {
		this.name = name;
		System.out.println("name: " + name + ", age: " + age);
		System.out.println("t: " + t.toString());
		System.out.println("v: " + v.toString());
		int sum = Arrays.stream(number).sum();

		System.out.println("the sum for the numbers:" + sum);

		if (null == t) {
			throw new NullPointerException();
		}

		return "teaphy";
	}

	public void doHomeWork(String work) {
		System.out.println("do " + work);
	}

	public int getAge() {
		return age;
	}

	protected void setAge(int age) {
		this.age = age;
	}

	private String getAddr() {
		return addr;
	}

	void setAddr(String addr) {
		this.addr = addr;
	}

	@Override
	public void doStudy() {
		System.out.println("do study");
	}

	@Override
	public void doSwim() {
		System.out.println("do swim");
	}

	/**
	 * 课程
	 */
	public class Course {

		String name;
		String score;
	}

	/**
	 * 兴趣
	 */
	private class Interest {

		String name;
	}

	protected class ProDemo {

		String name;
	}

	interface DefaultA {

	}

	@Override
	public String toString() {
		return "Student{" +
				"age=" + age +
				", sex=" + sex +
				", location=" + location +
				", addr='" + addr + '\'' +
				", sorted=" + sorted +
				", t=" + t +
				'}' + ", Pserson{"
				+
				"id=" + super.getId() +
				", name='" + super.getName() +
				'}';
	}
}
